<script type="text/javascript" language="JavaScript">
<!--
 function goto(url) {
  	window.status=('Connecting....')
 	var location=(SITE_URL + "admin/folders/contents/?path=" + url);
 	this.location.href = location;
 	window.status=('Connecting to ' + location + '  Please wait........');
}
//-->
</script>

<div id="page-heading"><h1><?php echo $crumbs; ?></h1></div>
<?php $this->load->view('partials/notices'); ?>
<table cellspacing="0" cellpadding="0" border="0" id="id-form">
	<tbody><tr>
		<td><?php echo lang('file_folders.subfolders_label'); ?>:</td>
		<td><?php echo form_dropdown('folder_path', $sub_folders, $folder->virtual_path, 'id="folder_path" class="select_box" onchange="goto(this.value)" style="width:150px;"'); ?></td>
		<td>&nbsp;</td>
		<td>[<?php echo anchor('admin/files/upload/'. $folder->id, lang('buttons.upload')); ?>]</td>
	</tr>
</tbody></table>

<?php if ($files): ?>
<?php echo form_open('admin/files/action', 'id="mainform"');?>
<table cellspacing="0" cellpadding="0" border="0" width="100%" id="product-table">
				<tbody>
				<tr>
				<?php if (group_has_role('files', 'delete')): ?>
					<th class="table-header-check"><a id="toggle-all" ></a> </th>
				<?php endif; ?>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('files.name_label'); ?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('files.type_label'); ?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('files.filename_label'); ?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('file_folders.created_label'); ?></a></th>
					<th class="table-header-repeat line-left"><a href="javascript:void(0);"><?php echo lang('global:actions')?></a></th>
				</tr>
				
				<?php foreach($files as $key => $file): ?>
				<tr <?php if($key%2 == 0):?>class="alternate-row"<?php endif;?>>
					<?php if (group_has_role('files', 'delete')): ?>
						<td> <?php echo form_checkbox('action_to[]', $file->id); ?></td>
					<?php endif; ?>
					<td><?php echo $file->name; ?></td>
					<td><a title="<?php echo $file->name; ?>" href="<?php echo base_url() . UPLOAD_PATH . 'files/' . $file->filename; ?>" rel="colorbox">
		                <img title="<?php echo $file->name; ?>" width="64" src="<?php echo site_url('files/thumb/' . $file->id . '/64/64?'. rand(0, 99)); ?>" alt="<?php echo $file->name; ?>" />
		            </a></td>
					<td><?php echo $file->filename; ?></td>
				<td class="align-center"><?php echo format_date($file->date_added); ?></td>
					<td class="options-width">
					<?php 	
					if (group_has_role('files', 'edit')) 
					{
						echo anchor('admin/files/edit/' . $file->id, ' ', 'class="icon-1 info-tooltip"');
					}
					
					if (group_has_role('files', 'delete')) 
					{
						echo anchor('admin/files/delete/' . $file->id, ' ', 'class="icon-2 info-tooltip"');
					}
					?>
					</td>
				</tr>
				<?php endforeach;?>
				</tbody>
</table>
<input type="hidden" name="btnAction"  id="btnAction" value=""/>
<input type="hidden" name="folder_id" value="<?php echo $folder->id?>"/>
<?php if (group_has_role('files', 'delete')): ?>
<script type="text/javascript">
	function submit_form(type)
	{
		if('delete' == type){
			$('#btnAction').val('delete');
			$('#mainform').submit();
		}
	}
</script>
<div id="actions-box">
	<a href="" class="action-slider"></a>
	<div id="actions-box-slider">
		<a href="javascript:void(0);" onclick="submit_form('delete');" class="action-delete"><?php echo lang('buttons.delete')?></a>
	</div>
	<div class="clear"></div>
</div>
<?php endif; ?>
<div align=center><div class="inner"><?php $this->load->view('partials/pagination'); ?></div></div>
<?php echo form_close();?>

<?php else: ?>
	<div class="no_data file-folders">
		<p><?php echo lang('files.no_files');?></p>
	</div>
<?php endif; ?>